/**
 * 
 */
package com.action;

import java.util.ArrayList;
import java.util.HashMap;

import org.apache.struts.action.ActionForward;

import admin.mode.AdminMode;
import admin.mode.MemberDispatchAction;
import admin.mode.MenuMode;
import base.Power;

/**
 * @author qsj
 * 
 */
public class FrameAction extends MemberDispatchAction {
	// 首页框架
	public ActionForward v_frame_index(Power power, AdminMode admin)
			throws Exception {
		// <bean:write name='leftMenu' property='LEFT_MENU_URL'/>
		power.setAttribute("LEFT_MENU_URL",
				"/FrameAction.do?opt=v_frame_index_left");
		power.setAttribute("RIGHT_MENU_URL",
				"/FrameAction.do?opt=v_frame_index_right");
		return power.findForward("/farme/cont.jsp", false);
	}

	@SuppressWarnings("unchecked")
	public ActionForward v_frame_index_top(Power power, AdminMode admin)
			throws Exception {
		MenuMode menuMode = new MenuMode();
		ArrayList topMenuList = menuMode.getTopMenuListByPerm(power, admin
				.getUserInfo().get("ROLE_ID").toString());
		// if (admin.getUserInfo().get("IS_SUPER").equals("1")) {//
		// 如查是super得到全部功能菜单
		// topMenuList = menuMode.getTopMenuList(power);
		// } else {// 否则只取有权限的
		// topMenuList = menuMode.getTopMenuListByPerm(power, admin
		// .getUserInfo().get("ROLE_ID").toString());
		// }
		power.setAttribute("topMenu", topMenuList);
		return power.findForward("/farme/top.jsp", false);
	}

	public ActionForward v_frame_index_main(Power power, AdminMode admin)
			throws Exception {
		power.setAttribute("LEFT_MENU_URL",
				"/FrameAction.do?opt=v_frame_index_left");
		power.setAttribute("RIGHT_MENU_URL",
				"/FrameAction.do?opt=v_frame_index_right");
		return power.findForward("/farme/main.jsp", false);
	}

	@SuppressWarnings("unchecked")
	public ActionForward v_frame_index_left(Power power, AdminMode admin)
			throws Exception {
		MenuMode menuMode = new MenuMode();
		ArrayList leftMenuList = menuMode.getLeftMenuByTopMenuId(power, "1");
		power.setAttribute("leftMenuList", leftMenuList);
		return power.findForward("/farme/left.jsp", false);
	}

	public ActionForward v_frame_index_right(Power power, AdminMode admin)
			throws Exception {
		return power.findForward("/page/analyse/findfarme.jsp", false);
	}

	// 策略管理
	// /FrameAction.do?opt=v_frame_policy_main
	public ActionForward v_frame_policy_main(Power power, AdminMode admin)
			throws Exception {
		power.setAttribute("LEFT_MENU_URL",
				"/FrameAction.do?opt=v_frame_policy_left");
		power.setAttribute("RIGHT_MENU_URL",
				"/FrameAction.do?opt=v_frame_policy_right");
		return power.findForward("/farme/cont.jsp", false);
	}

	public ActionForward v_frame_policy_right(Power power, AdminMode admin)
			throws Exception {
		return power.findForward("/page/analyse/findfarme.jsp", false);
	}

	@SuppressWarnings("unchecked")
	public ActionForward v_frame_policy_left(Power power, AdminMode admin)
			throws Exception {
		MenuMode menuMode = new MenuMode();
		ArrayList leftMenuList = menuMode.getLeftMenuByTopMenuId(power, "2");
		power.setAttribute("leftMenuList", leftMenuList);
		return power.findForward("/farme/left.jsp", false);
	}

	// 精细分析
	// /FrameAction.do?opt=v_frame_analysis_main
	public ActionForward v_frame_analysis_main(Power power, AdminMode admin)
			throws Exception {
		power.setAttribute("LEFT_MENU_URL",
				"/FrameAction.do?opt=v_frame_analysis_left");
		power.setAttribute("RIGHT_MENU_URL",
				"/FrameAction.do?opt=v_frame_analysis_right");
		return power.findForward("/farme/cont.jsp", false);
	}

	public ActionForward v_frame_analysis_right(Power power, AdminMode admin)
			throws Exception {
		return power.findForward("/page/analyse/find.jsp", false);
	}

	@SuppressWarnings("unchecked")
	public ActionForward v_frame_analysis_left(Power power, AdminMode admin)
			throws Exception {
		MenuMode menuMode = new MenuMode();
		ArrayList leftMenuList = menuMode.getLeftMenuByTopMenuId(power, "3");
		power.setAttribute("leftMenuList", leftMenuList);
		return power.findForward("/farme/left.jsp", false);
	}

	// 查询审计
	// /FrameAction.do?opt=v_frame_audit_main
	public ActionForward v_frame_audit_main(Power power, AdminMode admin)
			throws Exception {
		power.setAttribute("LEFT_MENU_URL",
				"/FrameAction.do?opt=v_frame_audit_left");
		power.setAttribute("RIGHT_MENU_URL",
				"/FrameAction.do?opt=v_frame_audit_right");
		return power.findForward("/farme/cont.jsp", false);
	}

	public ActionForward v_frame_audit_right(Power power, AdminMode admin)
			throws Exception {
		return power.findForward("/page/analyse/result.jsp", false);
	}

	@SuppressWarnings("unchecked")
	public ActionForward v_frame_audit_left(Power power, AdminMode admin)
			throws Exception {
		MenuMode menuMode = new MenuMode();
		ArrayList leftMenuList = menuMode.getLeftMenuByTopMenuId(power, "4");
		power.setAttribute("leftMenuList", leftMenuList);
		return power.findForward("/farme/left.jsp", false);
	}

	// 报表
	// /FrameAction.do?opt=v_frame_report_main
	public ActionForward v_frame_report_main(Power power, AdminMode admin)
			throws Exception {
		power.setAttribute("LEFT_MENU_URL",
				"/FrameAction.do?opt=v_frame_report_left");
		power.setAttribute("RIGHT_MENU_URL",
				"/FrameAction.do?opt=v_frame_report_right");
		return power.findForward("/farme/cont.jsp", false);
	}

	public ActionForward v_frame_report_right(Power power, AdminMode admin)
			throws Exception {
		return power.findForward("/page/analyse/findfarme.jsp", false);
	}

	@SuppressWarnings("unchecked")
	public ActionForward v_frame_report_left(Power power, AdminMode admin)
			throws Exception {
		MenuMode menuMode = new MenuMode();
		ArrayList leftMenuList = menuMode.getLeftMenuByTopMenuId(power, "5");
		power.setAttribute("leftMenuList", leftMenuList);
		return power.findForward("/farme/left.jsp", false);
	}

	// 报文管理
	// /FrameAction.do?opt=v_frame_tracelog_main
	public ActionForward v_frame_tracelog_main(Power power, AdminMode admin)
			throws Exception {
		power.setAttribute("LEFT_MENU_URL",
				"/FrameAction.do?opt=v_frame_tracelog_left");
		power.setAttribute("RIGHT_MENU_URL",
				"/FrameAction.do?opt=v_frame_tracelog_right");
		return power.findForward("/farme/cont.jsp", false);
	}

	public ActionForward v_frame_tracelog_right(Power power, AdminMode admin)
			throws Exception {
		return power.findForward("/page/analyse/findfarme.jsp", false);
	}

	@SuppressWarnings("unchecked")
	public ActionForward v_frame_tracelog_left(Power power, AdminMode admin)
			throws Exception {
		MenuMode menuMode = new MenuMode();
		ArrayList leftMenuList = menuMode.getLeftMenuByTopMenuId(power, "6");
		power.setAttribute("leftMenuList", leftMenuList);
		return power.findForward("/farme/left.jsp", false);
	}

	// 探测器
	// /FrameAction.do?opt=v_frame_search_main
	public ActionForward v_frame_search_main(Power power, AdminMode admin)
			throws Exception {
		power.setAttribute("LEFT_MENU_URL",
				"/FrameAction.do?opt=v_frame_search_left");
		power.setAttribute("RIGHT_MENU_URL",
				"/FrameAction.do?opt=v_frame_search_right");
		return power.findForward("/farme/cont.jsp", false);
	}

	public ActionForward v_frame_search_right(Power power, AdminMode admin)
			throws Exception {
		return power.findForward("/page/analyse/findfarme.jsp", false);
	}

	@SuppressWarnings("unchecked")
	public ActionForward v_frame_search_left(Power power, AdminMode admin)
			throws Exception {
		MenuMode menuMode = new MenuMode();
		ArrayList leftMenuList = menuMode.getLeftMenuByTopMenuId(power, "7");
		power.setAttribute("leftMenuList", leftMenuList);
		return power.findForward("/farme/left.jsp", false);
	}

	// 系统管理
	// /FrameAction.do?opt=v_frame_system_main
	public ActionForward v_frame_system_main(Power power, AdminMode admin)
			throws Exception {
		power.setAttribute("LEFT_MENU_URL",
				"/FrameAction.do?opt=v_frame_system_left");
		power.setAttribute("RIGHT_MENU_URL",
				"/FrameAction.do?opt=v_frame_system_right");
		return power.findForward("/farme/cont.jsp", false);
	}

	public ActionForward v_frame_system_right(Power power, AdminMode admin)
			throws Exception {
		return power.findForward("/page/analyse/findfarme.jsp", false);
	}

	@SuppressWarnings("unchecked")
	public ActionForward v_frame_system_left(Power power, AdminMode admin)
			throws Exception {
		MenuMode menuMode = new MenuMode();
		ArrayList leftMenuList = menuMode.getLeftMenuByTopMenuId(power, "8");
		power.setAttribute("leftMenuList", leftMenuList);
		if ((!admin.getUserInfo().get("IS_SUPER").equals("1"))
				&& admin.getUserInfo().get("ROLE_ID").equals("2")) {// 否则只取有权限的
			for (int i = 0; i < leftMenuList.size(); i++) {
				HashMap map = (HashMap) leftMenuList.get(i);
				if (map.get("LEFT_MENU_ID").equals("17")) {
					((ArrayList) map.get("leftThirdMenu")).remove(1);
				}
			}
		} else if ((!admin.getUserInfo().get("IS_SUPER").equals("1"))
				&& admin.getUserInfo().get("ROLE_ID").equals("4")) {// 否则只取有权限的
			for (int i = 0; i < leftMenuList.size(); i++) {
				HashMap map = (HashMap) leftMenuList.get(i);
				if (map.get("LEFT_MENU_ID").equals("17")) {
					((ArrayList) map.get("leftThirdMenu")).remove(0);
				}
			}
		}
		return power.findForward("/farme/left.jsp", false);
	}
}
